package 集合;

import javax.swing.text.StyledEditorKit;
import java.util.List;
import java.util.ListIterator;
import java.util.Random;

public class ListIteratorUse {
	public static void main(String[] args) {
		//	 listIterator 可以双向移动
		List<Integer> list = ListUse.createList();
		ListIterator<Integer> iterator = list.listIterator();
		while (iterator.hasNext()) {

			System.out.println(iterator.next());
			System.out.println(iterator.nextIndex());
			//System.out.println(iterator.previousIndex());
			//System.out.println(iterator.previous());
			//System.out.println(iterator.hasPrevious());
		}
		while (iterator.hasPrevious()){
			System.out.println(iterator.previous() +"::previous");
		}
		iterator = list.listIterator(3);
		while (iterator.hasNext()) {
			iterator.next();
			iterator.set(new Random().nextInt());
		}
		System.out.println(list);
	}
}
